Skip to content

Fix #843: avoid non-constant format strings in pybind_main.cpp#844

Merged
mhucka merged 3 commits intomasterfrom
mh-fix-843
Aug 15, 2025
Merged

Fix #843: avoid non-constant format strings in pybind_main.cpp#844
mhucka merged 3 commits intomasterfrom
mh-fix-843

Conversation

@mhucka
Copy link
Copy Markdown
Collaborator

@mhucka mhucka commented Jul 31, 2025

The CodeQL bot says of code on line 690 (and other cases in this file):

The printf function, related functions like sprintf and fprintf, and other functions built atop vprintf all accept a format string as one of their arguments. When such format strings are literal constants, it is easy for the programmer (and static analysis tools) to verify that the format specifiers (such as %s and %02x) in the format string are compatible with the trailing arguments of the function call. When such format strings are not literal constants, it is more difficult to maintain the program: programmers (and static analysis tools) must perform non-local data-flow analysis to deduce what values the format string argument might take.

The fix is easy enough: add a format string.

The CodeQL bot says of code on line 690 (and other cases in this file):

> The printf function, related functions like sprintf and fprintf, and other functions built atop vprintf all accept a format string as one of their arguments. When such format strings are literal constants, it is easy for the programmer (and static analysis tools) to verify that the format specifiers (such as %s and %02x) in the format string are compatible with the trailing arguments of the function call. When such format strings are not literal constants, it is more difficult to maintain the program: programmers (and static analysis tools) must perform non-local data-flow analysis to deduce what values the format string argument might take.
@mhucka mhucka self-assigned this Jul 31, 2025
@github-actions github-actions Bot added the size: S 10< lines changed <50 label Jul 31, 2025
@mhucka mhucka changed the title Fix #843: avoid non-constant format strings in calls to IO:errorf Fix #843: avoid non-constant format strings in pybind_main.cpp Aug 10, 2025
@mhucka mhucka marked this pull request as ready for review August 14, 2025 02:55
@mhucka mhucka merged commit 9261c18 into master Aug 15, 2025
49 checks passed
@mhucka mhucka deleted the mh-fix-843 branch August 15, 2025 19:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size: S 10< lines changed <50

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants